<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>管理员控制面板</title>
    <!-- 引入Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <div class="container-fluid">
        <a class="navbar-brand" href="#">图书馆管理系统 - 管理员控制面板</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarNav">
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link active" aria-current="page" href="#">首页</a>
                </li>
                <c:if test="${sessionScope.user.type==1}">
                    <li class="nav-item">
                        <a class="nav-link" href="userServlet?path=getUsersByName">管理用户</a>
                    </li>
                </c:if>
                <li class="nav-item">
                    <a class="nav-link" href="listBooksServlet">图书列表</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="listBorrowsServlet">借阅记录</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="fineServlet">罚款列表</a>
                </li>
            </ul>
            <ul class="navbar-nav ms-auto">
                <li class="nav-item">
                    <a class="nav-link" href="logout.jsp">注销登录</a>
                </li>
                <li class="nav-item">
                    <c:if test="${not empty sessionScope.user}">
                        <span class="nav-link">当前登录用户：${sessionScope.user.username}</span>
                    </c:if>
                </li>
            </ul>
        </div>
    </div>
</nav>

<div class="container mt-5">
    <h2>欢迎${sessionScope.user.type==1?"管理员":"用户"}，以下是系统概览：</h2>
    <div class="row">
        <c:if test="${sessionScope.user.type==1}">
            <div class="col-md-4">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">用户总数</h5>
                        <p class="card-text">${totalUsers}</p>
                    </div>
                </div>
            </div>
        </c:if>
        <div class="col-md-4">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">图书总数</h5>
                    <p class="card-text">${totalBooks}</p>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">当前借阅数量</h5>
                    <p class="card-text">${borrowedBooksCount}</p>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 引入Bootstrap JS（用于导航栏折叠等交互功能） -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>

</html>